﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web.Security;
using System.Text.RegularExpressions;
using System.Data.Common;
using System.Security.Cryptography;
using Model;
using Model.FA_DataSetTableAdapters;
using Model.IRepository;
using Model.Repository;
using System.Web.Services;

namespace ASP_FORMS
{
    public partial class Login : System.Web.UI.Page
    {        
        protected void Page_Load(object sender, EventArgs e)
        {            
            if (User.Identity.IsAuthenticated)
            {
                Response.Redirect("Default.aspx");
            }
        }

        protected void btn_Login_Click(object sender, EventArgs e)
        {
            try
            {
                CheckUser cu = new CheckUser();
                if (!cu.IsValidUser(txt_Username.Text, txt_Password.Text))
                {
                    lbl_status.Text = "<li>Invalid Login Credentials...!</li>";
                }
                else
                {
                    FormsAuthentication.RedirectFromLoginPage(txt_Username.Text, true);
                }
            }
            catch (Exception ex)
            {
            }
        }

        protected void btn_Register_Click(object sender, EventArgs e)
        {
            Response.Redirect("Register.aspx", true);
        }
    }
}